# == Schema Information
#
# Table name: sales_finance_infos
#
#  id              :integer          not null, primary key
#  name            :string(255)
#  invoice_type    :integer
#  tax_num         :string(255)
#  bank_name       :string(255)
#  account_num     :string(255)
#  invoice_address :string(255)
#  phone           :string(255)
#  notes           :string(255)
#  firm_id         :integer
#  contact_id      :integer
#  as_default      :boolean
#  active          :boolean          default(TRUE)
#  created_at      :datetime         not null
#  updated_at      :datetime         not null
#

class Sales::FinanceInfo < ApplicationRecord
  extend Enumerize


  belongs_to :firm, class_name: 'Sales::Firm', foreign_key: 'firm_id'

  INVOICE_TYPE = {company: 1, person: 2}

  enumerize :invoice_type, in: INVOICE_TYPE,  predicates: {prefix: true}, scope: true

  validates_presence_of :invoice_type, message: '请选择开票类型'
  validates_presence_of :name, message: '请填写开票抬头'


end
